package com.itheima.service.company.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.company.CompanyDao;
import com.itheima.domain.company.Company;
import com.itheima.service.company.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {
    @Autowired
    private CompanyDao companyDao;

    @Override
    public List<Company> findAll() {
        //PageHelper.startPage(page,pageSize)
        return companyDao.findAll();
    }
    //分页查询操作   page:页码    pageSize：每页显示条数
    @Override
    public PageInfo<Company> findAll(int page,int pageSize) {
        PageHelper.startPage(page,pageSize);
        List<Company> all = companyDao.findAll();//select * from ss_company limit 1,10
        return new PageInfo<>(all,3);
    }

    @Override
    public void save(Company company) {
        companyDao.save(company);
    }

    @Override
    public void update(Company company) {
        companyDao.update(company);
    }

    @Override
    public void delete(String id) {
        companyDao.delete(id);
    }

    @Override
    public Company findById(String id) {
        return companyDao.findById(id);
    }
}
